// 新闻文章接口都在这里
import request from '../utils/request'

export const getPostAPI = (params) =>{
    return request({
        method:'GET',
        url:'/post',
        params:params,
    })
}
// 文章详情
export const getPostDetailByIdAPI =(id)=>{
    return request({
        method:'GET',
        url:`/post/${id}`,
    })
}

// 文章点赞和取消点赞是同一个接口
export const updatePostLikeByIdAPI =(id)=>{
    return request({
        method:"GET",
        url:`/post_like/${id}`,
    })
}
// 收藏文章
export const updatePostStarByIdAPI =(id)=>{
    return request({
        method:"GET",
        url: `/post_star/${id}`,
    })
}
// 5. 评论列表 
export const getPostCommentByIdAPI = (id,params) => {
    return request({
      method: 'GET',
      url: `/post_comment/${id}`,
      params:params,
    })
  }
  
  // 6. 发表评论
  export const publishPostCommentAPI = (id, data) => {
    return request({
      method: 'POST',
      url: `/post_comment/${id}`,
      data,
    })
  }
  //  编辑文章
export const updatePostAPI = (id, data) => {
    return request({
      method: 'POST',
      url: `/post_update/${id}`,
      data: data,
    })
  }

  // 搜索文章
export const getPostSearchAPI = (params) => {
  return request({
    method: 'GET',
    url: '/post_search',
    params,
  })
}